package com.shuoyue.ycgk.ui.shop;

import android.text.TextUtils;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shuoyue.ycgk.R;
import com.shuoyue.ycgk.base.baseadapter.AppBaseQuickAdapter;
import com.shuoyue.ycgk.entity.GoodsItem;
import com.shuoyue.ycgk.entity.ShopItem;

import java.util.List;

public class ShopAdapter extends AppBaseQuickAdapter<ShopItem> {
    public ShopAdapter(@Nullable List<ShopItem> data) {
        super(R.layout.item_shop, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ShopItem item) {
        helper.addOnClickListener(R.id.lay_all);
        helper.setText(R.id.title, item.getName());
        helper.setText(R.id.sold, "已售" + item.getSalesVolume());
        Glide.with(mContext).load(item.getCover()).error(R.mipmap.img_loading_gray).into((ImageView) helper.getView(R.id.img));
        helper.setGone(R.id.lay_price, item.getDefaultPrice() != null);
        if (item.getDefaultPrice() != null) {
            helper.setText(R.id.price, "￥" + item.getDefaultPrice().getPrice());
            helper.setText(R.id.price_org, "￥" + item.getDefaultPrice().getOriginalPrice());
            helper.setGone(R.id.price_org, !TextUtils.isEmpty(item.getDefaultPrice().getOriginalPrice()));
        }

    }
}
